import { Component, OnInit, Input, EventEmitter, Output} from '@angular/core';

import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
import { Service } from '../../../server/server'
import {HintsService} from '../../../public/serve/hints/hints.service';
import { ActivatedRoute } from '@angular/router';
declare var $: any;


@Component({
  selector: 'app-themetable-tag-delete',
  templateUrl: './themetable-tag-delete.component.html',
})
export class ThemetableTagDeleteComponent implements OnInit {

  constructor(private activatedRoute: ActivatedRoute,private hintsService: HintsService,private removeTableService: RemoveTableService, private server: Service) { }
  @Input() details: any;
  ngOnInit() {
    this.activatedRoute.url.subscribe(r => {
      this.removeTableService._clearId("labelId");
    })
  }
  @Output()
  deleteOutput: EventEmitter<string> = new EventEmitter();
  // 确认删
  confirmDel() {
    let url = this.server.baseUrl + 'Service/ThemeWords/deleteThemeTableLabel';
    this.removeTableService.confirmRemove('ids', url).then((res: any) => {
      this.deleteOutput.emit(res.result_code);
      if (res.result_code == '0000') {
        $("#delete").modal("hide");
      }
      this.removeTableService._clearId("labelId");
      this.hintsService.messages(res.message, res.result_code);
    }).catch(err => {
        this.hintsService.messages('error','error');
        return;
    });
  }

}
